package logic

import (
	"context"
	"errors"
	"gitignore/models/mysql"

	"gitignore/gitignorerpc/gitignorerpc"
	"gitignore/gitignorerpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoDelLogic {
	return &VideoDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *VideoDelLogic) VideoDel(in *gitignorerpc.VideoDelRequest) (*gitignorerpc.VideoDelResponse, error) {
	// todo: add your logic here and delete this line
	var video mysql.Video

	err := video.FindVideoByDel(mysql.DB, in.VideoId)
	if err != nil {
		return nil, errors.New("下架失败")
	}
	return &gitignorerpc.VideoDelResponse{
		VideoId: int64(video.ID),
	}, nil
}
